package com.weipai.education.dao.impl;

import com.weipai.education.dao.UserDao;
import com.weipai.education.mapper.ApplicationUserMapper;
import com.weipai.education.mapper.UserMapper;
import com.weipai.education.model.ApplicationUser;
import com.weipai.education.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/12/10 15:50
 */
@Repository
public class UserDaoImpl implements UserDao {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ApplicationUserMapper applicationUserMapper;

    @Override
    public int update(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public int insert(User user) {
        return userMapper.insert(user);
    }

    @Override
    public User selectByPrimaryKey(String id) {
        return userMapper.selectByPrimaryKey(Integer.parseInt(id));
    }

    @Override
    public List<Map<String, Object>> list(Integer start, Integer size,
                                          Integer userCateId, String key, String userId) {
        return userMapper.list(start, size, userCateId, key, userId);
    }
    @Override
    public List<Map<String, Object>> Mylist(Integer start, Integer size,
                                          Integer userCateId, String key, String userId) {
        return userMapper.Mylist(start, size, userCateId, key, userId);
    }

    @Override
    public Integer listAmount(Integer userCateId, String key, String userId) {
        return userMapper.listAmount(userCateId, key, userId);
    }
    @Override
    public Integer MylistAmount(Integer userCateId, String key, String userId) {
        return userMapper.MylistAmount(userCateId, key, userId);
    }

    @Override
    public int batchDeleteById(String[] id) {
        return userMapper.batchDeleteById(id);
    }

    @Override
    public List<User> getUserByRoleId(String roleId) {
        return userMapper.getUserByRoleId(roleId);
    }

    @Override
    public User getUserByMobile(String mobile) {
        return userMapper.getUserByMobile(mobile);
    }

    @Override
    public Integer saveApplicationUser(ApplicationUser applicationUser) {
        return applicationUserMapper.insert(applicationUser);
    }

    @Override
    public int getUserByAccountNumber(String accountNumber) {
        return userMapper.getUserByAccountNumber(accountNumber);
    }

    @Override
    public User getUserModelByAccountNumber(String referrerAccountNumber) {
        return userMapper.getUserModelByAccountNumber(referrerAccountNumber);
    }

    @Override
    public List<Map<String, Object>> searchAccountNumber(String accountNumber) {
        return userMapper.searchAccountNumber(accountNumber);
    }

    @Override
    public List<Map<String, Object>> applicationUserList(Integer start, Integer size, Integer userCateId, String key, 
                                                            String isAudit, String userId) {
        return applicationUserMapper.applicationUserList(start, size, userCateId, key, isAudit, userId);
    }

    @Override
    public Integer applicationUserAmount(Integer userCateId, String key, String isAudit, String userId) {
        return applicationUserMapper.applicationUserAmount(userCateId, key, isAudit, userId);
    }

    @Override
    public ApplicationUser selectApplicationUserByPrimaryKey(String id) {
        return applicationUserMapper.selectByPrimaryKey(Integer.parseInt(id));
    }

    @Override
    public int updateApplicationUser(ApplicationUser applicationUser) {
        return applicationUserMapper.updateByPrimaryKeySelective(applicationUser);
    }
    
    @Override
    public Integer allListAmount(Integer userCateId, String key) {
        return userMapper.allListAmount(userCateId, key);
    }

    @Override
    public Map<String, Object> getUserInfoByUserId(String userId) {
        return userMapper.getUserByUserId(userId);
    }

    @Override
    public int updateByPrimaryKeySelective(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public User getCityCountyUser(String province,String city, String county, int flag) {
        return userMapper.getCityCountyUser(province,city, county, flag);
    }

    @Override
    public List<Map<String, Object>> userList(Integer start, Integer size, Integer roleId, String key) {
        return userMapper.userList(start, size, roleId, key);
    }

    @Override
    public Integer userListAmount(Integer roleId, String key) {
        return userMapper.userListAmount(roleId, key);
    }

    @Override
    public int verifyUserByAddress(Integer flag, String province, String city, String county) {
        return userMapper.verifyUserByAddress(flag, province, city, county);
    }

    @Override
    public User getUserByAddress(Integer flag, String province, String city, String county) {
        return userMapper.getUserByAddress(flag, province, city, county);
    }

    @Override
    public List<Map<String, Object>> getUserByAddressAndFlag(String province, String city, int flag2, int flag1) {
        return userMapper.getUserByAddressAndFlag(province, city, flag2, flag1);
    }

    @Override
    public Integer getUserByAddressAndFlagAmount(String province, String city, Integer userCateId, int flag2, int flag1, String key) {
        return userMapper.getUserByAddressAndFlagAmount(province, city, userCateId, flag2, flag1, key);
    }

    @Override
    public List<Map<String, Object>> getUserByAddressAndFlagTwo(Integer start, Integer end, Integer userCateId, 
                                                                String province, String city, int flag2, int flag1, String key) {
        return userMapper.getUserByAddressAndFlagTwo(start, end, userCateId, province, city, flag2, flag1, key);
    }

}
